package cn.itsource.basic.config;

import cn.itsource.user.interceptor.LoginInfoInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/*@Configuration*/
public class SpringMVCConfigurer implements WebMvcConfigurer {
    @Autowired
    private LoginInfoInterceptor loginInfoInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInfoInterceptor)
                .addPathPatterns("/**")//拦截所有资源
                .excludePathPatterns("/login")//放行登录
                .excludePathPatterns("/shop")//放行商家入驻
                .excludePathPatterns("/user/register")//放行用户注册
                .excludePathPatterns("/verification//sendMobileCode")//验证码
                .excludePathPatterns("/fastDfs/upload");//放行图片上传
    }
}
